<?php
/*
 * siteMap生成
 */
class Libs_SiteMap_Helper {

    protected static $_dbAdmin;
    public static function loadDb() {
        self::$_dbAdmin = Db_Admin::instance();
    }
    /*
     * 生成cms的sitemap
     */
    public static function createCmsSiteMap($paramArr){
        if (is_array($paramArr)) {
            $options = array(
                'appId'     => 1,
            );
            $options = array_merge($options, $paramArr);
            extract($options);
        }
        //获得记录
        $param = array(
            'cnt'    => 5000,
            'appId'  => $appId,
            'orderBy' => ' order by datetm desc ',#
        );
        $data = Libs_Cms_Document::getDocumentList($param);
        if($data){
             $dataArr = array();
             $lastmoddt = date('Y-m-d');
             foreach($data as $d){
                 $dataArr[] = array(
                        'loc'         => $d['url'],
                        'lastmod'     => $lastmoddt,
                        'changefreq'  => 'daily',
                        'priority'    => '0.8',

                );
             }

            //获得APP的配置信息
            $appCfg = ME_Config::get('APP','CONFIG');
            $appCfg = $appCfg[$appId];
            $basePath = PRODUCTION_ROOT . '/Html/' . $appCfg['webPath'] . '/xml/';

            $sitemapObj = new Libs_SiteMap_Common();
            $sitemapObj->createContent($dataArr,$basePath . 'sitemap.xml');

            $sitemapObj = new Libs_SiteMap_Baidu();
            $sitemapObj->createContent($dataArr,$basePath . 'baidu_sitemap.xml');
            
        }
        
    }



}

?>
